int buttonPin = 6;
int relayPin = 7;
int relayState = LOW;
int buttonState;
int lastButtonState = LOW;
long lastDebounceTime = 0;
long debounceDelay = 10;

void setup() {
  // put your setup code here, to run once:
  pinMode(buttonPin,INPUT);
  pinMode(relayPin,OUTPUT);

  digitalWrite(relayPin,relayState);
}

void loop() {
  // put your main code here, to run repeatedly:
  int reading = digitalRead(buttonPin);
  if(reading != lastButtonState){
    lastDebounceTime = millis();
  }
  if((millis()-lastDebounceTime)>debounceDelay){
    if(reading != buttonState){
      buttonState = reading;

      if(buttonState == HIGH){
        relayState = !relayState;
      }
    }
  }
  digitalWrite(relayPin,relayState);

  lastButtonState = reading;
}
